Warning cleanup. Restore functionality of 'no garmin devices found' for now.
authorrobertl <robertl>
Fri, 27 Jun 2008 17:05:27 +0000 (17:05 +0000)
committerrobertl <robertl>
Fri, 27 Jun 2008 17:05:27 +0000 (17:05 +0000)
garmin.c
garmin_device_xml.c
garmin_device_xml.h
jeeps/gpslibusb.c

index 997db4577643a2e0e64567a9dd00e46feb5c329c..1336ec18f62ad17aa0be4e797e534f06eec1f4d2 100644 (file)
--- a/garmin.c
+++ b/garmin.c
@@ -253,7 +253,7 @@ rd_init(const char *fname)
 {
        if (setjmp(gdx_jmp_buf)) {
                char *vec_opts = NULL;
-               gdx_info *gi = gdx_get_info();
+               const gdx_info *gi = gdx_get_info();
                gpx_vec = find_vec("gpx", &vec_opts);
                gpx_vec->rd_init(gi->from_device.canon);
        } else {
index 268670f69169ef3941ecd22772ac76358f7a58db..0e7222b0a42d3e44f52a2969091f2a497a96836f 100644 (file)
@@ -105,9 +105,15 @@ static xg_tag_mapping gdx_map[] = {
 
 const gdx_info *
 gdx_read(const char *fname) {
-  xml_init(fname, gdx_map, NULL);
-  xml_read();
-  xml_deinit();
+  // Test file open-able before gb_open gets a chance to fatal().
+  FILE *fin = fopen(fname, "r");
+
+  if (fin) {
+    fclose(fin);
+    xml_init(fname, gdx_map, NULL);
+    xml_read();
+    xml_deinit();
+  }
 
   return my_gdx_info;
 }
@@ -119,8 +125,8 @@ gdx_find_file(char **dirlist) {
   const gdx_info *gdx;
   while (*dirlist) {
     char *tbuf;
-    xasprintf(&tbuf, "%s/%s", dirlist, "GarminDevice.xml");
-    mountpoint = dirlist;
+    xasprintf(&tbuf, "%s/%s", *dirlist, "GarminDevice.xml");
+    mountpoint = *dirlist;
     gdx = gdx_read(tbuf);
     xfree(tbuf);
     if (gdx) {
index bc90ecd873c06e43dc7f95badec13886a516eadf..ffc6b31af1e1d3de6236719b969aee4e44241efe 100644 (file)
  * Describes a file on the unit.
  */
 typedef struct {
-       const char *path;
-       const char *basename;
-       const char *extension;
-       const char *canon;      // full name, when applicable.
+       char *path;
+       char *basename;
+       char *extension;
+       char *canon;    // full name, when applicable.
 } gdx_file;
 
 /*
index 20b5313818bb65c9019ee16009ba5f557dee17fe..3ddb08464b34838fd439c8c71ccffcdae204605b 100644 (file)
@@ -325,7 +325,8 @@ int garmin_usb_scan(libusb_unit_data *lud, int req_unit_number)
                 * that is wants to read and write GPX files on a 
                 * mounted drive.  Try that now.
                 */
-               gdx = gdx_find_file(".");
+char *dlist[] = { ".", NULL}; 
+               gdx = gdx_find_file(dlist);
                if (gdx) return 1;
                /* Plan C. */
                fatal("Found no Garmin USB devices.\n");